﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Tanmia.Warehouse.Core;
using Tanmia.Basis.Domain;
using Tanmia.Basis.Data;

namespace Tanmia.Warehouse.Domain
{
    public class DiscriminatorDomain : BaseDomain<Discriminator>
    {
        public DiscriminatorDomain(ISessionManager sessionManager)
            : base(sessionManager)
        {
        }

        public IList<Discriminator> GetsWithHead()
        {
            IList<Discriminator> discriminators = Gets();
            discriminators.Insert(0, Discriminator.HeadItem);
            return discriminators;
        }

        public IList<Discriminator> GetsParentWithHead(Discriminator entity)
        {
            //IList<Discriminator> discriminators = Gets(x => x.ElementID != entity.ElementID);
            IList<Discriminator> discriminators = (from discriminator in Repository.RepositoryItems
                                                   where discriminator.ElementID != entity.ElementID
                                                   select discriminator).ToList<Discriminator>();

            discriminators.Insert(0, Discriminator.HeadItem);
            return discriminators;
        }
    }
}
